.TH byte_starts 3
.SH NAME
byte_starts \- find out if a buffer starts with a string
.SH SYNTAX
.B #include <libowfat/byte.h>

int \fBbyte_starts\fP(const char *\fIbuf\fR,size_t \fIbuflen\fR,const char *\fIstr\fR);
.SH DESCRIPTION
\fIbyte_starts\fR returns 1 if the \fIbuflen\fR>=strlen(\fIstr\fR) and the first
strlen(\fIstr\fR) bytes of \fIbuf\fR match the contents of \fIstr\fR, or
0 otherwise.

This function is meant to be used in protocol parsing and with a string
constant for \fIstr\fR and will use gcc/clang macro trickery to reduce to a call to
\fImemcmp\fR then.

\fIbyte_starts\fR compares as few bytes as possible. An attacker observing
the execution timing can thus learn where the first mismatch happened.

Use \fIbyte_equal_notimingattack\fR to compare keys, passphrases, cookies or
hashes instead.

.SH "SEE ALSO"
byte_equal(3), byte_equal_notimingattack(3), byte_start(3)
